async function fetchWeatherData(cityCode) {
    const url = `http://t.weather.itboy.net/api/weather/city/${cityCode}`;

    try {
        const response = await fetch(url);
        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }
        const data = await response.json();
        console.log('Weather data:', data);
        return data; // 返回获取的天气数据
    } catch (error) {
        console.error('Could not fetch weather data:', error);
    }
}

async function getWeatherForecast(cityCode) {
    try {
        const weatherData = await fetchWeatherData(cityCode);
        const { city, updateTime } = weatherData.cityInfo;
        const { wendu, shidu, quality, ganmao } = weatherData.data;
        const weatherSummary = `当前${city}的天气：温度${wendu}℃，湿度${shidu}，空气质量${quality}。${ganmao}`;
        console.log(weatherSummary);
    } catch (error) {
        console.error('Could not get weather forecast:', error);
    }
}

// 调用函数获取天气预报，并存储在 weatherData 变量中
const weatherData = getWeatherForecast('101180101');
console.log(weatherData); // 这里会输出一个 Promise 对象，因为 getWeatherForecast 是异步函数
